<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.filter.TekunaFilter');


	/**
	 * This filter implementation escapes all special XML characters
	 * with their octal entity notation. The following characters are
	 * changed: &, <, >, ", '
	 */

	class XMLSpecialCharsFilter implements TekunaFilter {


		/**
		 * Transforms the input
		 *
		 * @param mixed $mInput
		 * @return string
		 */

		public function filter($mInput) {

			$mInput = str_replace('&', '&#38;', $mInput);
			$mInput = str_replace('<', '&#60;', $mInput);
			$mInput = str_replace('>', '&#62;', $mInput);
			$mInput = str_replace('"', '&#34;', $mInput);
			$mInput = str_replace('\'', '&#39;', $mInput);

			return $mInput;
		}
	}
